<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/api.js"></script>
    <script type="text/javascript" src="./script/aui-tab.js"></script>
    <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
    <style>
        body {}
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" id="topbar">投资理财-可大金服</header>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript">
    var iosNarHeight;
    var picH;
    var bottomH;

    apiready = function() {

        var deviceModel = api.deviceModel;
        if (deviceModel.indexOf('iPhone10') > -1) {
            iosNarHeight = 70;
            picH = -35;
            bottomH = -10;
        } else {
            iosNarHeight = 50;
            picH = 0;
            bottomH = 7;
        }

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.closeWidget();
        });
        addTabbar();

        if (api.systemType == 'ios') {

            var password = $api.getStorage('password');
            if (password) {
                api.addEventListener({
                    name: 'resume'
                }, function(ret, err) {
                    api.openWin({
                        name: 'ios-unlock',
                        url: './ios-unlock.html',
                        bgColor: '#00744b',
                        slidBackEnabled: false,
                        pageParam: {
                            name: 'test'
                        }
                    });
                });
            }


        } else {
            androidLock();
        }
    };


    function androidLock() {
        //添加解锁验证
        var isLock = $api.getStorage('isLock');
        if (isLock) {
            var b = false;
            api.addEventListener({
                name: 'pause'
            }, function(ret, err) {
                b = true;
            });
            api.addEventListener({
                name: 'resume'
            }, function(ret, err) {
                buy = $api.getStorage('buy');
                var buy;
                if (buy == 'true') {
                    $api.setStorage('buy', 0);
                    return;
                }

                if (b) {
                    var screenLock = api.require('screenLock');
                    screenLock.show({
                        color: '#00744b'
                    }, function(ret, err) {
                        if (ret.status == '111') {
                            b = false;
                        }
                    });
                };
            });
        }
    }




    function addTabbar(selected) {
        var selectedIndex;
        if (selected) {
            selectedIndex = selected;
        } else {
            selectedIndex = 0;
        }

        var h = api.winHeight;

        $api.fixStatusBar($api.dom('#topbar'));
        var headerPos = $api.offset($api.dom('#topbar'));

        var NVTabBar = api.require('NVTabBar');
        NVTabBar.open({
                styles: {
                    bg: '#fff',
                    //bg:"widget://image/NVTabBar/tabbar_bg.png",
                    h: iosNarHeight,
                    dividingLine: {
                        width: 0,
                        color: '#000'
                    },
                    badge: {
                        bgColor: '#fff',
                        numColor: '#fff',
                        size: 6.0,
                        centerX: 40,
                        centerY: 6
                    }
                },
                items: [{
                    w: api.winWidth / 4.0,
                    bg: {
                        marginB: picH,
                        // image: 'rgba(200,200,200,0.6)'
                    },
                    iconRect: {
                        w: 20.0,
                        h: 20.0,
                    },
                    icon: {
                        normal: 'widget://image/NVTabBar/home.png',
                        highlight: 'widget://image/NVTabBar/homeed.png',
                        selected: 'widget://image/NVTabBar/homeed.png',
                    },
                    title: {

                        text: '首页',
                        size: 12.0,
                        normal: '#515151',
                        selected: '#00744b',
                        marginB: bottomH,
                    }
                }, {
                    w: api.winWidth / 4.0,
                    bg: {
                        marginB: picH,
                        // image: 'rgba(200,200,200,0.7)'
                    },
                    iconRect: {
                        w: 20.0,
                        h: 20.0,
                    },
                    icon: {
                        normal: 'widget://image/NVTabBar/licai.png',
                        highlight: 'widget://image/NVTabBar/licaied.png',
                        selected: 'widget://image/NVTabBar/licaied.png',
                    },
                    title: {
                        text: '投资理财',
                        size: 12.0,
                        normal: '#515151',
                        selected: '#00744b',
                        marginB: bottomH,
                    }
                }, {
                    w: api.winWidth / 4.0,
                    bg: {
                        marginB: picH,
                        // image: 'widget://image/NVTabBar/yyuan.png' //中间背景图
                    },
                    iconRect: {
                        w: 20.0,
                        h: 20.0,
                    },
                    icon: {
                        normal: 'widget://image/NVTabBar/user.png',
                        highlight: 'widget://image/NVTabBar/usered.png',
                        selected: 'widget://image/NVTabBar/usered.png',
                    },
                    title: {
                        text: '我的账户',
                        size: 12.0,
                        normal: '#515151',
                        selected: '#00744b',
                        marginB: bottomH,
                    }
                }, {
                    w: api.winWidth / 4.0,
                    bg: {
                        marginB: picH,
                        // image: 'rgba(200,20,0,0.6)'
                    },
                    iconRect: {
                        w: 20.0,
                        h: 20.0,
                    },
                    icon: {
                        normal: 'widget://image/NVTabBar/more.png',
                        highlight: 'widget://image/NVTabBar/moreed.png',
                        selected: 'widget://image/NVTabBar/moreed.png',
                    },
                    title: {
                        text: '更多',
                        size: 12.0,
                        normal: '#515151',
                        selected: '#00744b',
                        marginB: bottomH,
                    }
                }],
                selectedIndex: selectedIndex
            },

            function(ret, err) {
                api.openFrameGroup({
                    name: 'nav',
                    background: '#fff',
                    scrollEnabled: false,
                    rect: {
                        x: 0,
                        y: 0,
                        w: 'auto',
                        h: h - 50
                    },
                    preload: 0,
                    index: 0,
                    frames: [{
                        name: 'index',
                        url: './index.html',
                        bgColor: '#fff'
                    }, {
                        name: 'licai-list',
                        url: './licai-list.html',
                        bgColor: '#fff'
                    }, {
                        name: 'user',
                        url: './user.html',
                        bgColor: '#fff'
                    }, {
                        name: 'more_list',
                        url: 'more-list.html',
                        bgColor: '#fff'
                    }]
                }, function(ret, err) {

                });

                if (ret.index == 1) {

                    api.setFrameGroupAttr({
                        name: 'nav',
                        rect: {
                            x: 0,
                            y: headerPos.h,
                            w: api.frameWidth,
                            h: api.winHeight - headerPos.h - iosNarHeight
                        }
                    });
                } else {
                    api.setFrameGroupAttr({
                        name: 'nav',
                        rect: {
                            x: 0,
                            y: 0,
                            w: api.frameWidth,
                            h: api.winHeight - iosNarHeight
                        }
                    });

                }
                api.hideProgress();
                // 如果是个人中心,则刷新页面
                if (ret.index == 2 || 3) {
                    api.setFrameGroupIndex({
                        name: 'nav',
                        index: ret.index,
                        reload: true,
                    });
                } else {
                    api.setFrameGroupIndex({
                        name: 'nav',
                        index: ret.index,
                    });
                }
            });
    }

    // 退出登录后 第三个按钮选中
    function changeSelect() {
        var NVTabBar = api.require('NVTabBar');
        NVTabBar.setSelect({
            index: 2,
            selected: true,
        });
    }

    function changeSelect_licai() {
        $api.fixStatusBar($api.dom('#topbar'));
        var headerPos = $api.offset($api.dom('#topbar'));

        var NVTabBar = api.require('NVTabBar');
        NVTabBar.setSelect({
            index: 1,
            selected: true,
        });

        api.setFrameGroupIndex({
            name: 'nav',
            index: 1,
            reload: true,
        });
        api.setFrameGroupAttr({
            name: 'nav',
            rect: {
                x: 0,
                y: headerPos.h,
                w: api.frameWidth,
                h: api.winHeight - headerPos.h - iosNarHeight
            }
        });

    }

    function gotoUser() {
        api.setFrameGroupAttr({
            name: 'nav',
            rect: {
                x: 0,
                y: 0,
                w: api.frameWidth,
                h: api.winHeight - iosNarHeight
            }
        });


        // 登录成功后 跳转到user页面调用刷新数据方法
        api.setFrameGroupIndex({
            name: 'nav',
            index: 2,
            reload: true,
        });
        changeSelect();
    }

    function gotoLicai() {


        // $('#topbar').show();
        // 登录成功后 跳转到user页面调用刷新数据方法
        api.setFrameGroupIndex({
            name: 'nav',
            index: 1,
            reload: true,
        });

        $api.fixStatusBar($api.dom('#topbar'));
        var headerPos = $api.offset($api.dom('#topbar'));
        api.setFrameGroupAttr({
            name: 'nav',
            rect: {
                x: 0,
                y: headerPos.h,
                w: api.frameWidth,
                h: api.winHeight - headerPos.h - iosNarHeight
            }
        });

        var NVTabBar = api.require('NVTabBar');
        NVTabBar.setSelect({
            index: 1,
            selected: true,
        });
    }

    function closeLoginFrame() {
        api.closeFrame({
            name: 'login'
        });
    }




    function reload() {
      api.closeWin({
          name: 'ios-unlock'
      });
      api.toast({
          msg: '解锁失败',
          duration: 2000,
          location: 'middle'
      });

      setTimeout("opeanReload()", 400);


    }

    function opeanReload() {
        api.openWin({
            name: 'ios-unlock',
            url: './ios-unlock.html',
            bgColor: '#00744b',
            slidBackEnabled: false,
        });

    }
</script>

</html>
